$(document).ready(function(){
    var typenames = new Array('clazzTop3byScore','clazzTop3byNO');
    //根据排行榜的数量，循环发送ajax 查询最新的redis结果，依次将结果放入对应的div显示
    //为了回避，ajax回调函数，不是先发送就一定先拿到返回值（每个不同ajax是不同的线程），就有多少个排行榜先生成多少个ul
    var rankDiv = "<div class='rank'>";
    for(var i=0;i<typenames.length;i++) {
        var rankUl = "<ul class='rankUl' alt='"+typenames[i]+"'></ul>";
        rankDiv += rankUl;
    }
    rankDiv += "</div>";
    $('#ranklist').append(rankDiv);
    setInterval(function(){refershRank();},10000);//js定时器 ajax发送

    function refershRank() {
        $('.rankUl').html('');//清空全部的排行榜
        for (var i = 0; i < typenames.length; i++) {
            $.ajax({
                "url": "chart/queryCharts/" + typenames[i],
                "data": {},
                "dataType": "json",
                "type": "post",
                "success": function (dto) {

                    //将返回值循环 组成排行榜
                    var ranklis = "";
                    var typeName;
                    $(dto.tList).each(function (i, chart) {
                        ranklis += "<li><div class='rankno'>" + chart.no + "</div><div class='rankDetail'>" +
                            "<div class='rankImg'><img src=''></div>" +
                            "<div class='rankInfo'>" + chart.name + "</div>" +
                            "<div class='rankInfo'>" + chart.value + "</div>" +
                            "</div></li>";
                        typeName=chart.typeName;
                        console.log(typeName);
                    });

console.log( $(".rankUl[alt='"+typeName+"']").attr('alt'));
                    $(".rankUl[alt='"+typeName+"']").append(ranklis);//是第几个ajax回调函数的内容就 追加到第几个ul
                }
            });
        }
    }
});

$('.tt[alt="name"]').text();